<?php
namespace app\common\model;
use think\Model;
class Alarm_table extends Model
{
	/**
     * 获取某字段信息
     */
    public function getOne($field,$where){
        $result = self::field($field)->where($where)->find();
        if($result){
            $result = $result->getData();
        }
        return $result;
    }

    /**
     * 删
     * @param $id
     * @return int
     */
    public function del($where){
        return self::where($where)->delete();
    }

    /**
     * 更改字段信息
     * @param $id
     * @param $data
     * @return $this
     */
    public function updInfo($where,$data){
        return self::where($where)->update($data);
    }

    /**
     * 排序全部查询
     * @param $where
     * @param $pageSize
     * @param array $pageParam
     * @return \think\Paginator
     */
    public function getAll($where,$order,$pageSize,$pageParam=[],$field="*"){
        $result=self::order($order)->field($field);
        if ($where){
            $result->where($where);
        }
        return $result->paginate($pageSize,false,$pageParam);

    }

    /**
     * 获取警报列表
     * @param int $end 结束时间
     * @return array
     * */
    public function devAll($where=[],$field="*",$order='st desc'){
        $result = self::order($order)->field($field);
        
        if ($where){
            $result->where($where);
        }
        $result = $result->select();

        return $result;
    }
}